x86: avoid leaking PKRU and BND* between vCPU-s
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:36:51 +0000 (14:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:36:51 +0000 (14:36 +0200)
commitde20bb6c4f65c4161e0931402613f9ffac86302d
tree5626396db62a1f3659d4bf1813dcbf85dd75151a
parent26217aff67ae1538d4e1b2226afab6993cdbe772
x86: avoid leaking PKRU and BND* between vCPU-s

PKRU is explicitly "XSAVE-managed but not XSAVE-enabled", so guests
might access the register (via {RD,WR}PKRU) without setting XCR0.PKRU.
Force context switching as well as migrating the register as soon as
CR4.PKE is being set the first time.

For MPX (BND<n>, BNDCFGU, and BNDSTATUS) the situation is less clear,
and the SDM has not entirely consistent information for that case.
While experimentally the instructions don't change register state as
long as the two XCR0 bits aren't both 1, be on the safe side and enable
both if BNDCFGS.EN is being set the first time.

This is XSA-220.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hvm.c